package top.xphu.utils;

import java.util.Random;

/**
 * @author xphu
 * @version 1.0
 * @date 2021/11/11 11:27
 */
public class RandomNameUtil {
    private static Random random = new Random();
    private final static int delta = 0x9fa5 - 0x4e00 + 1;

    /**
     * 获取随机文字
     * @return 文字
     */
    public static char getWord(){
        return (char)(0x4e00 + random.nextInt(delta));
    }

    /**
     * 获取随机名称
     * @param num 几个字的名称
     * @return 名称
     */
    public static String getName(int num){
        StringBuilder name = new StringBuilder();
        for (int i = 0; i < num; i++) {
            name.append(getWord());
        }
        return name.toString();
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            System.out.println(RandomNameUtil.getName(3));
        }
    }
}
